package com.zy.servlet.marks;

import com.zy.service.AddMarksService;
import com.zy.service.impl.AddMarksServiceImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;


    @WebServlet("/addMark")
    public class AddMarksServlet extends HttpServlet {
        private AddMarksService addMarksService = new AddMarksServiceImpl();

        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            String content = request.getParameter("content");
            int userId = Integer.parseInt(request.getParameter("userId"));
            boolean success = addMarksService.addMark(content, userId);
            response.setContentType("application/json");
            response.getWriter().write("{\"success\": " + success + "}");
        }
    }
